// pages/message/type/index.js
const $api = require("../../../api/message").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    msglists:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var t = this
    t.setData({
      dict_key:options.dict_key
    })
    t.getMessageList()
  },


  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var t = this
    t.setData({
      page:t.data.page +1 
    })
    t.getMessageList()
  },
  
  // 消息列表
  getMessageList(data){
    var t = this,
    data = {
      member_id:wx.getStorageSync('memberinfo').member_id,
      message_type:t.data.dict_key,
      pageNo:t.data.page,
      child_id:"",
    }
    $api.getMessageList(data).then(res=>{
      var msglists = t.data.msglists
      msglists = msglists.concat(res.data)
      t.setData({
        msglists:msglists
      })
    })
  
  },
  gotomessageinfo(e){
    var t = this
    wx.navigateTo({
      url:'/pages/message/info/index?id='+e.currentTarget.dataset.id
    })
  },
})